package com.xbongbong.pro.enums.menu.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.MenuTypeEnum;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

@Getter
public enum MarketManagementMenuEnum {

    // 市场管理
    MARKET_ACTIVITY(XbbRefTypeEnum.MARKET_ACTIVITY.getName(), XbbRefTypeEnum.MARKET_ACTIVITY.getAlias(), XbbRefTypeEnum.MARKET_ACTIVITY.getCode(),
            AccessLinkEnum.MARKET_ACTIVITY, "", MenuTypeEnum.FORM.getType()),
    CLUE(XbbRefTypeEnum.CLUE.getName(), XbbRefTypeEnum.CLUE.getAlias(), XbbRefTypeEnum.CLUE.getCode(),
            AccessLinkEnum.CLUE, "", MenuTypeEnum.GROUP.getType()),
    ALL_CLUE(XbbRefTypeEnum.ALL_CLUE.getName(), XbbRefTypeEnum.ALL_CLUE.getAlias(), XbbRefTypeEnum.ALL_CLUE.getCode(),
            AccessLinkEnum.All_CLUE, XbbRefTypeEnum.CLUE.getAlias(), MenuTypeEnum.FORM.getType()),
    CLUE_PUBLIC(XbbRefTypeEnum.CLUE_PUBLIC.getName(), XbbRefTypeEnum.CLUE_PUBLIC.getAlias(), XbbRefTypeEnum.CLUE_PUBLIC.getCode(),
            AccessLinkEnum.CLUE_PUBLIC, XbbRefTypeEnum.CLUE.getAlias(), MenuTypeEnum.FORM.getType()),
    CLUE_DUPLICATE(XbbRefTypeEnum.CLUE_DUPLICATE.getName(), XbbRefTypeEnum.CLUE_DUPLICATE.getAlias(), XbbRefTypeEnum.CLUE_DUPLICATE.getCode(),
            AccessLinkEnum.CLUE_DUPLICATE, XbbRefTypeEnum.CLUE.getAlias(), MenuTypeEnum.MENU.getType()),
    CLUE_RECYCLE(XbbRefTypeEnum.CLUE_RECYCLE.getName(), XbbRefTypeEnum.CLUE_RECYCLE.getAlias(), XbbRefTypeEnum.CLUE_RECYCLE.getCode(),
            AccessLinkEnum.CLUE_RECYCLE, XbbRefTypeEnum.CLUE.getAlias(), MenuTypeEnum.FORM.getType()),
    ;
    /**
     * saas应用标示解释
     */
    private String name;
    /**
     * saas应用标示
     * @see XbbRefTypeEnum
     */
    private String alias;
    /**
     * @see XbbRefTypeEnum
     */
    private Integer code;
    /**
     * 对应的链接
     */
    private AccessLinkEnum accessLinkEnum;

    /**
     * 父节点，如果没有父节点，则此值为空字符串
     */
    private String parent;

    /**
     * 类型
     * @see MenuTypeEnum
     */
    private Integer type;


    MarketManagementMenuEnum(String name, String alias, Integer code, AccessLinkEnum accessLinkEnum, String parent, Integer type){
        this.name = name;
        this.alias = alias;
        this.code = code;
        this.accessLinkEnum = accessLinkEnum;
        this.parent = parent;
        this.type = type;
    }

    public static MarketManagementMenuEnum getByAlias(String alias) {
        for(MarketManagementMenuEnum marketManagementMenuEnum: values()) {
            if(marketManagementMenuEnum.getAlias().equals(alias)){
                return marketManagementMenuEnum;
            }
        }
        return null;
    }

    public static MarketManagementMenuEnum getByCode(Integer code) {
        for(MarketManagementMenuEnum marketManagementMenuEnum: values()) {
            if(marketManagementMenuEnum.getCode().equals(code)){
                return marketManagementMenuEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
